<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<button>设置美女图片作为网页的背景-主题</button>
		<script type="text/javascript">
			// localStorage 长期存放数据
			// sessionStorage 当次会话有效，短期存放数据
			var btn = document.querySelector('button')
			// btn.onclick = function(){
			// 	localStorage.imgUrl = "http://nanxing.jiankang4.com/uploadfile/2012/0312/20120312063520871.jpg"
			// 	document.body.style.backgroundImage = "url("+localStorage.imgUrl+")"
			// }
			// document.body.style.backgroundImage = "url("+localStorage.imgUrl+")"
			
			
			btn.onclick = function(){
				sessionStorage.imgUrl = "http://nanxing.jiankang4.com/uploadfile/2012/0312/20120312063520871.jpg"
				document.body.style.backgroundImage = "url("+sessionStorage.imgUrl+")"
			}
			document.body.style.backgroundImage = "url("+sessionStorage.imgUrl+")"
		
			var obj = {username:"老陈",age:18}
			// JSON.stringify将对象转为JSON格式的字符串
			console.log(JSON.stringify(obj))
			
			localStorage.obj = JSON.stringify(obj)
			// JSON.parse将JSON格式的字符串转为对象
			var obj1 = JSON.parse(localStorage.obj)
		</script>
	</body>
</html>
